package com.hardroid.workload.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hardroid.workload.R;
import com.hardroid.workload.utils.ResultQuestAdapter;
import com.hardroid.workload.utils.Singleton;

public class ResultQuestFragment extends ResultFragment {

	public ResultQuestAdapter adapter;

	// status employer
	private TextView nameText;
	private TextView divisionText;
	private TextView unitText;
	private TextView jobText;
	
	private TextView rata2KelonggaranText;
	private TextView rata2PenyesuaianText;

	private TextView structuralText;
	private TextView genderText;

	public ResultQuestFragment() {
		// TODO Auto-generated constructor stub
		super();
	}

	public ResultQuestFragment(int id) {
		// TODO Auto-generated constructor stub
		super(id);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		return inflater.inflate(R.layout.fragment_result_quest, container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);

		nameText = (TextView) getView().findViewById(R.id.result_employer_name);
		divisionText = (TextView) getView().findViewById(
				R.id.result_employer_division);
		unitText = (TextView) getView().findViewById(R.id.result_employer_unit);
		jobText = (TextView) getView().findViewById(R.id.result_employer_job);
		
		rata2KelonggaranText= (TextView) getView().findViewById(R.id.result_rata_rata_kelonggaran);
		rata2PenyesuaianText= (TextView) getView().findViewById(R.id.result_rata_rata_penyesuaian);

		employer = Singleton.currentProject.lEmployer.get(employerId);
		adapter = new ResultQuestAdapter(getActivity(),
				employer.sheet.lObsvDay);

		setListAdapter(adapter);
		
		updateView();
	}

	private void updateView() {
		// TODO Auto-generated method stub
	
		nameText.setText(employer.name);
		divisionText.setText(employer.division);
		jobText.setText(employer.job);
		unitText.setText(employer.unit);
		genderText = (TextView) getView().findViewById(R.id.result_employer_male);
		structuralText = (TextView) getView().findViewById(R.id.result_employer_structural);
		
		
		if(employer.structural){
			structuralText.setText("Structural");
		}else{
			structuralText.setText("Non - structural");	
		}
		
		if (employer.male){
			genderText.setText("Laki-laki");
		}else{
			genderText.setText("Perempuan");	
		}
		
//		
		rata2KelonggaranText.setText(employer.sheet.getRata2Kelonggaran()+"");
		rata2PenyesuaianText.setText(employer.sheet.getRata2Penyesuaian()+"");
//		
//		confidenceText.setText(employer.result.confidenceLevel+"");
//		accuracyText.setText(employer.result.accuracyLevel+"");
		
		
	}

	public static ResultQuestFragment createInstance(int id) {
		ResultQuestFragment retval = new ResultQuestFragment(id);
		return retval;
	}
}
